﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tycho.Runtime;

namespace Tycho.Peyote {
    /// <summary>
    /// Interaction logic for SetGlyph.xaml
    /// </summary>
    public partial class SetGlyph : UserControl {
        Environment Environment;
        AnyObject Set;

        public SetGlyph (AnyObject set, Environment environment) {
            InitializeComponent ();

            Environment = environment;
            Set = set;

            PopulateSetItems ();
        }

        void PopulateSetItems () {
            foreach (AnyObject item in Set) {
                StackPanel.Children.Add (Environment.Presenter.Present (item));
            }
        }
    }

    public class SetPresenter : GlyphPresenter {
        public SetPresenter () : base ("set", new TypeSchemaObject<SetObject> ()) { }

        public override UIElement Present (AnyObject obj, Environment environment) {
            return new SetGlyph (obj, environment);
        }
    }
}
